package com.caosy.grassthinkremote.controller;

import com.caosy.grassthinkremote.common.RespData;
import com.caosy.grassthinkremote.entity.vo.UserReqVo;
import com.caosy.grassthinkremote.service.UserService;
import com.caosy.grassthinkremote.util.JwtUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    private PasswordEncoder passwordEncoder;

    @Autowired
    private JwtUtil jwtUtil;

    @Autowired
    private RedisTemplate redisTemplate;

    @Autowired
    private UserService userService;

    @PostMapping("/auth")
    @ResponseBody
    public RespData loginAuth(@RequestBody UserReqVo req,HttpServletRequest request) {
        return userService.loginAuth(req,request);
    }

    @PostMapping("/adminAddUser")
    @ResponseBody
    public RespData adminAddUser(@RequestBody UserReqVo req, HttpServletRequest request) {
        return userService.adminAddUser(req,request);
    }

    @PostMapping("/isLogin")
    @ResponseBody
    public RespData isLogin() {
        return RespData.getSuccess("已登录！");
    }
}
